<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
require 'connection.php';
    
   	try{
   		$con = connect();
   		
   		$name = $_POST['name'];
   		$place = $_POST['place'];
   		$date = $_POST['date'];
   		$hour = $_POST['hour'];
   		$urlImage = $_POST['urlImage'];
   		
   		if($urlImage == NULL){
   			$targetPath = "null";
   		}else{
   			$targetPath = "http://alquimiabtl.com/secured/aplicaciones/notificaciones/uploads/" . $urlImage;
   		}
   		
   		$sqlInsNotificacion = "INSERT INTO notificacion (nombre, estado, lugar, fecha, hora, imagen)
            VALUES (?, '1', ?, ?, ?, ?);";
   		
   		$stmInsNotificacion = $con->prepare($sqlInsNotificacion);
   		$stmInsNotificacion->bind_param("sssss",$name,$place,$date,$hour,$targetPath);
   		$stmInsNotificacion->execute();
   		$stmInsNotificacion->close();
   		
   		mysqli_close($con);
   		echo 'successful';
   	}catch (Exception $e){    
         echo $e->getMessage();
    }  
        
?>
